using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Register : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
        // Set the title of the page
        this.Title = HunterShopConfiguration.SiteName +
        " : Rejestracja";
        /*
        if(!IsPostBack)
        {            
            //((DropDownList).CreateUserStep.ContentTemplateContainer.FindControl("regionDropDownList")).SelectedValue; 
        }*/
    }
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        string aaa;
        CreateUserWizard cuw = (CreateUserWizard)sender;
        cuw.Email = cuw.UserName; 

        Roles.AddUserToRole((sender as CreateUserWizard).UserName,"Customers");


        // Create an empty Profile for the newly created user
        ProfileCommon p = (ProfileCommon)ProfileCommon.Create(cuw.UserName, true);

        // Populate some Profile properties off of the create user wizard
        p.FirstName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("firstNameTextBox")).Text;
        p.LastName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("lastNameTextBox")).Text;
        p.Address1 = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("address1TextBox")).Text;
        p.Address2 = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("address2TextBox")).Text;
        p.City = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("cityTextBox")).Text;
        p.Region = ((DropDownList)cuw.CreateUserStep.ContentTemplateContainer.FindControl("regionDropDownList")).SelectedValue;
        p.PostCode = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("postCodeTextBox")).Text;
        p.Country = ((DropDownList)cuw.CreateUserStep.ContentTemplateContainer.FindControl("countryDropDownList")).SelectedValue;
        p.Phone = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("phoneTextBox")).Text;
        p.Fax = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("faxTextBox")).Text;
        p.CompanyName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("companyNameTextBox")).Text;
        p.CompanyNip = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("companyNipTextBox")).Text;

        //p.Age = Int32.Parse(((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Age")).Text);

        // Save profile - must be done since we explicitly created it 
        p.Save();
    }
}
